package subject_set.offer100;

/**
 * @author haomin
 * @date 2022/10/22 18:07
 **/
public class Offer52 {
    class Solution {
        ListNode getIntersectionNode(ListNode headA, ListNode headB) {
            ListNode node1 = headA;
            ListNode node2 = headB;
            while(node1 != node2){
                node1 = node1 == null ? headB : node1.next;
                node2 = node2 == null ? headA : node2.next;
            }
            return node1;
        }
    }
}